package com.hellobike.haxing.modules.wms.service.impl;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hellobike.haxing.modules.wms.entity.ShippingDetail;
import com.hellobike.haxing.modules.wms.enums.ShippingTypeEnum;
import com.hellobike.haxing.modules.wms.mapper.ShippingDetailMapper;
import com.hellobike.haxing.modules.wms.service.IShippingDetailService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Description: t_wms_shipping_detail
 * @Author: haxing-boot
 * @Date:   2020-02-02
 * @Version: V1.0
 */
@Service
public class ShippingDetailServiceImpl extends ServiceImpl<ShippingDetailMapper, ShippingDetail> implements IShippingDetailService {

    @Override
    public void removeByHeaderId(Long shippingHeaderId) {
        ShippingDetail q = new ShippingDetail();
        q.setShippingHeaderId(shippingHeaderId);
        Wrapper<ShippingDetail> wrapper = new UpdateWrapper<>(q);
        baseMapper.delete(wrapper);
    }

    @Override
    public List<ShippingDetail> getByHeaderId(Long shippingHeaderId) {
        ShippingDetail q = new ShippingDetail();
        q.setShippingHeaderId(shippingHeaderId);
        Wrapper<ShippingDetail> wrapper = new QueryWrapper<>(q);
        return baseMapper.selectList(wrapper);
    }

    @Override
    public ShippingDetail getByDeliveryOrderIdAndType(Long headerId, ShippingTypeEnum typeEnum) {
        return baseMapper.getByDeliveryOrderIdAndType(headerId,typeEnum.getValue());
    }
}
